package com.catmiw.swt;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;

public class StudyAssistant extends BasicWindow{
	private Properties properties;
	public StudyAssistant(){
		properties=new Properties();
		try {
			properties.load(new FileReader("d:/test.properties"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		new StudyAssistant().open();
		
	}

	@Override
	public void createContents() {
		shell.setText("王奕卓学习助手V0.1");
		addMenu();
	}
	
	public void addMenu(){
		Menu menubar=new Menu(shell,SWT.BAR);
		shell.setMenuBar(menubar);
		
		MenuItem basictrainning=new MenuItem(menubar,SWT.CASCADE);
		basictrainning.setText("基础训练");
		
		Menu basictrainningMenu=new Menu(shell,SWT.DROP_DOWN);
		basictrainning.setMenu(basictrainningMenu);
		
		MenuItem copybookItem = new MenuItem(basictrainningMenu, SWT.PUSH);
		copybookItem.setText("&C.字帖...");
		copybookItem.setAccelerator(SWT.CTRL+'c');
		
		copybookItem.addSelectionListener(new SelectionListener(){
			public void widgetSelected(SelectionEvent e) {
				Properties p=new Properties();
				DialogCopybook copybookDialog=new DialogCopybook(shell);
				copybookDialog.setProperties(properties);
				copybookDialog.open();
			}

			public void widgetDefaultSelected(SelectionEvent e) {
			}
			
		});
	}

}
